package com.itheima.socket.udp.demo02;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class ReceiveDemo02 {

    public static void main(String[] args) throws IOException {

        DatagramSocket datagramSocket = new DatagramSocket(7777);
        while (true) {
//            Byte[] bytes = new Byte[1024];
            byte[] bytes = new byte[1024];
            int length = bytes.length;
            DatagramPacket datagramPacket = new DatagramPacket(bytes, length);

            datagramSocket.receive(datagramPacket);
            byte[] data = datagramPacket.getData();
            int length1 = data.length;
            System.out.println(new String(data, 0, length1));
        }
    }

}
